﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using Extra.ERP;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_PROCESS_POSITION
    {
        private DateTime m_Date;
        private string m_DecideNumber;
        private string m_EmployeeCode;
        private string m_NewBranch;
        private string m_NewDepartment;
        private string m_NewGroup;
        private string m_NewPosition;
        private string m_OldBranch;
        private string m_OldDepartment;
        private string m_OldGroup;
        private string m_OldPosition;
        private string m_Person;
        private Guid m_PositionID;
        private string m_Reason;

        public HRM_PROCESS_POSITION()
        {
            this.m_PositionID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_OldBranch = "";
            this.m_OldDepartment = "";
            this.m_OldGroup = "";
            this.m_OldPosition = "";
            this.m_NewBranch = "";
            this.m_NewDepartment = "";
            this.m_NewGroup = "";
            this.m_NewPosition = "";
            this.m_Date = DateTime.Now;
            this.m_Reason = "";
            this.m_DecideNumber = "";
            this.m_Person = "";
        }

        public HRM_PROCESS_POSITION(Guid PositionID, string EmployeeCode, string OldBranch, string OldDepartment, string OldGroup, string OldPosition, string NewBranch, string NewDepartment, string NewGroup, string NewPosition, DateTime Date, string Reason, string DecideNumber, string Person)
        {
            this.m_PositionID = PositionID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_OldBranch = OldBranch;
            this.m_OldDepartment = OldDepartment;
            this.m_OldGroup = OldGroup;
            this.m_OldPosition = OldPosition;
            this.m_NewBranch = NewBranch;
            this.m_NewDepartment = NewDepartment;
            this.m_NewGroup = NewGroup;
            this.m_NewPosition = NewPosition;
            this.m_Date = Date;
            this.m_Reason = Reason;
            this.m_DecideNumber = DecideNumber;
            this.m_Person = Person;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { this.m_PositionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_POSITION_Delete", myParams, myValues);
        }

        public string Delete(Guid PositionID)
        {
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { PositionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_POSITION_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid PositionID)
        {
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { PositionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_POSITION_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid PositionID)
        {
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { PositionID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_POSITION_Delete", myParams, myValues);
        }

        public bool Exist(Guid PositionID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { PositionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_POSITION_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid PositionID)
        {
            string str = "";
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { PositionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_PROCESS_POSITION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PositionID = reader.GetGuid(reader.GetOrdinal("PositionID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_OldBranch = Convert.ToString(reader["OldBranch"]);
                    this.m_OldDepartment = Convert.ToString(reader["OldDepartment"]);
                    this.m_OldGroup = Convert.ToString(reader["OldGroup"]);
                    this.m_OldPosition = Convert.ToString(reader["OldPosition"]);
                    this.m_NewBranch = Convert.ToString(reader["NewBranch"]);
                    this.m_NewDepartment = Convert.ToString(reader["NewDepartment"]);
                    this.m_NewGroup = Convert.ToString(reader["NewGroup"]);
                    this.m_NewPosition = Convert.ToString(reader["NewPosition"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid PositionID)
        {
            string str = "";
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { PositionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_PROCESS_POSITION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PositionID = reader.GetGuid(reader.GetOrdinal("PositionID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_OldBranch = Convert.ToString(reader["OldBranch"]);
                    this.m_OldDepartment = Convert.ToString(reader["OldDepartment"]);
                    this.m_OldGroup = Convert.ToString(reader["OldGroup"]);
                    this.m_OldPosition = Convert.ToString(reader["OldPosition"]);
                    this.m_NewBranch = Convert.ToString(reader["NewBranch"]);
                    this.m_NewDepartment = Convert.ToString(reader["NewDepartment"]);
                    this.m_NewGroup = Convert.ToString(reader["NewGroup"]);
                    this.m_NewPosition = Convert.ToString(reader["NewPosition"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid PositionID)
        {
            string str = "";
            string[] myParams = new string[] { "@PositionID" };
            object[] myValues = new object[] { PositionID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_PROCESS_POSITION_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PositionID = reader.GetGuid(reader.GetOrdinal("PositionID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_OldBranch = Convert.ToString(reader["OldBranch"]);
                    this.m_OldDepartment = Convert.ToString(reader["OldDepartment"]);
                    this.m_OldGroup = Convert.ToString(reader["OldGroup"]);
                    this.m_OldPosition = Convert.ToString(reader["OldPosition"]);
                    this.m_NewBranch = Convert.ToString(reader["NewBranch"]);
                    this.m_NewDepartment = Convert.ToString(reader["NewDepartment"]);
                    this.m_NewGroup = Convert.ToString(reader["NewGroup"]);
                    this.m_NewPosition = Convert.ToString(reader["NewPosition"]);
                    this.m_Date = Convert.ToDateTime(reader["Date"]);
                    this.m_Reason = Convert.ToString(reader["Reason"]);
                    this.m_DecideNumber = Convert.ToString(reader["DecideNumber"]);
                    this.m_Person = Convert.ToString(reader["Person"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetAllList()
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code" };
            object[] myValues = new object[] { level, code };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_POSITION_GetAllList", myParams, myValues);
        }

        public DataTable GetAllListByDays(DateTime BeginDate, DateTime EndDate)
        {
            int level = MyLogin.Level;
            string code = MyLogin.Code;
            string[] myParams = new string[] { "@Level", "@Code", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { level, code, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_POSITION_GetAllListByDays", myParams, myValues);
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_POSITION_GetList");
        }

        public DataTable GetListByDays(string EmployeeCode, DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { EmployeeCode, BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_POSITION_GetListByDays", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_POSITION_GetListByEmployee", myParams, myValues);
        }

        public DataTable GetListByMonth(string EmployeeCode, int Month, int Year)
        {
            string[] myParams = new string[] { "@EmployeeCode", "@Month", "@Year" };
            object[] myValues = new object[] { EmployeeCode, Month, Year };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_PROCESS_POSITION_GetListByMonth", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { this.m_PositionID, this.m_EmployeeCode, this.m_OldBranch, this.m_OldDepartment, this.m_OldGroup, this.m_OldPosition, this.m_NewBranch, this.m_NewDepartment, this.m_NewGroup, this.m_NewPosition, this.m_Date, this.m_Reason, this.m_DecideNumber, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_POSITION_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { this.m_PositionID, this.m_EmployeeCode, this.m_OldBranch, this.m_OldDepartment, this.m_OldGroup, this.m_OldPosition, this.m_NewBranch, this.m_NewDepartment, this.m_NewGroup, this.m_NewPosition, this.m_Date, this.m_Reason, this.m_DecideNumber, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_POSITION_Insert", myParams, myValues);
        }

        public string Insert(Guid PositionID, string EmployeeCode, string OldBranch, string OldDepartment, string OldGroup, string OldPosition, string NewBranch, string NewDepartment, string NewGroup, string NewPosition, DateTime Date, string Reason, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { PositionID, EmployeeCode, OldBranch, OldDepartment, OldGroup, OldPosition, NewBranch, NewDepartment, NewGroup, NewPosition, Date, Reason, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_POSITION_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid PositionID, string EmployeeCode, string OldBranch, string OldDepartment, string OldGroup, string OldPosition, string NewBranch, string NewDepartment, string NewGroup, string NewPosition, DateTime Date, string Reason, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { PositionID, EmployeeCode, OldBranch, OldDepartment, OldGroup, OldPosition, NewBranch, NewDepartment, NewGroup, NewPosition, Date, Reason, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_POSITION_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid PositionID, string EmployeeCode, string OldBranch, string OldDepartment, string OldGroup, string OldPosition, string NewBranch, string NewDepartment, string NewGroup, string NewPosition, DateTime Date, string Reason, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { PositionID, EmployeeCode, OldBranch, OldDepartment, OldGroup, OldPosition, NewBranch, NewDepartment, NewGroup, NewPosition, Date, Reason, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_POSITION_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_PROCESS_POSITION", "JobCode", "CV");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { this.m_PositionID, this.m_EmployeeCode, this.m_OldBranch, this.m_OldDepartment, this.m_OldGroup, this.m_OldPosition, this.m_NewBranch, this.m_NewDepartment, this.m_NewGroup, this.m_NewPosition, this.m_Date, this.m_Reason, this.m_DecideNumber, this.m_Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_POSITION_Update", myParams, myValues);
        }

        public string Update(Guid PositionID, string EmployeeCode, string OldBranch, string OldDepartment, string OldGroup, string OldPosition, string NewBranch, string NewDepartment, string NewGroup, string NewPosition, DateTime Date, string Reason, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { PositionID, EmployeeCode, OldBranch, OldDepartment, OldGroup, OldPosition, NewBranch, NewDepartment, NewGroup, NewPosition, Date, Reason, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_PROCESS_POSITION_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid PositionID, string EmployeeCode, string OldBranch, string OldDepartment, string OldGroup, string OldPosition, string NewBranch, string NewDepartment, string NewGroup, string NewPosition, DateTime Date, string Reason, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { PositionID, EmployeeCode, OldBranch, OldDepartment, OldGroup, OldPosition, NewBranch, NewDepartment, NewGroup, NewPosition, Date, Reason, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_PROCESS_POSITION_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid PositionID, string EmployeeCode, string OldBranch, string OldDepartment, string OldGroup, string OldPosition, string NewBranch, string NewDepartment, string NewGroup, string NewPosition, DateTime Date, string Reason, string DecideNumber, string Person)
        {
            string[] myParams = new string[] { "@PositionID", "@EmployeeCode", "@OldBranch", "@OldDepartment", "@OldGroup", "@OldPosition", "@NewBranch", "@NewDepartment", "@NewGroup", "@NewPosition", "@Date", "@Reason", "@DecideNumber", "@Person" };
            object[] myValues = new object[] { PositionID, EmployeeCode, OldBranch, OldDepartment, OldGroup, OldPosition, NewBranch, NewDepartment, NewGroup, NewPosition, Date, Reason, DecideNumber, Person };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_PROCESS_POSITION_Update", myParams, myValues);
        }

        [DisplayName("Date"), Category("Column")]
        public DateTime Date
        {
            get
            {
                return this.m_Date;
            }
            set
            {
                this.m_Date = value;
            }
        }

        [Category("Column"), DisplayName("DecideNumber")]
        public string DecideNumber
        {
            get
            {
                return this.m_DecideNumber;
            }
            set
            {
                this.m_DecideNumber = value;
            }
        }

        [DisplayName("EmployeeCode"), Category("Column")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("NewBranch"), Category("Column")]
        public string NewBranch
        {
            get
            {
                return this.m_NewBranch;
            }
            set
            {
                this.m_NewBranch = value;
            }
        }

        [Category("Column"), DisplayName("NewDepartment")]
        public string NewDepartment
        {
            get
            {
                return this.m_NewDepartment;
            }
            set
            {
                this.m_NewDepartment = value;
            }
        }

        [Category("Column"), DisplayName("NewGroup")]
        public string NewGroup
        {
            get
            {
                return this.m_NewGroup;
            }
            set
            {
                this.m_NewGroup = value;
            }
        }

        [DisplayName("NewPosition"), Category("Column")]
        public string NewPosition
        {
            get
            {
                return this.m_NewPosition;
            }
            set
            {
                this.m_NewPosition = value;
            }
        }

        [Category("Column"), DisplayName("OldBranch")]
        public string OldBranch
        {
            get
            {
                return this.m_OldBranch;
            }
            set
            {
                this.m_OldBranch = value;
            }
        }

        [DisplayName("OldDepartment"), Category("Column")]
        public string OldDepartment
        {
            get
            {
                return this.m_OldDepartment;
            }
            set
            {
                this.m_OldDepartment = value;
            }
        }

        [Category("Column"), DisplayName("OldGroup")]
        public string OldGroup
        {
            get
            {
                return this.m_OldGroup;
            }
            set
            {
                this.m_OldGroup = value;
            }
        }

        [DisplayName("OldPosition"), Category("Column")]
        public string OldPosition
        {
            get
            {
                return this.m_OldPosition;
            }
            set
            {
                this.m_OldPosition = value;
            }
        }

        [DisplayName("Person"), Category("Column")]
        public string Person
        {
            get
            {
                return this.m_Person;
            }
            set
            {
                this.m_Person = value;
            }
        }

        [Category("Primary Key"), DisplayName("PositionID")]
        public Guid PositionID
        {
            get
            {
                return this.m_PositionID;
            }
            set
            {
                this.m_PositionID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_PROCESS_POSITION";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [DisplayName("Reason"), Category("Column")]
        public string Reason
        {
            get
            {
                return this.m_Reason;
            }
            set
            {
                this.m_Reason = value;
            }
        }
    }
}

